<?php
namespace Crm\Controller;

/**
 * 通用上传处理控制器
 * xxaction, xxname, xxmodel
 * @author SoChishun <14507247@qq.com>
 * @since 1.0.0 <2015-3-28> SoChishun Added.
 */
class UploadHandlerController extends AppbaseController {
    
    /**
     * 检测用户访问权限
     * @since 1.0 <2015-3-28> SoChishun Added.
     */
    public function assert_upr($rule = '') {
        $upr = array(
            'xxaction_list' => true,
            'xxaction_edit' => true,
        );

        $this->user_permission_rules = $upr;
        if ($rule && (!array_key_exists($rule, $upr) || !$upr[$rule])) {
            die('您没有访问权限!');
        }
    }
    
    /**
     * kindeupload操作
     * @since 1.0 2015-3-28 SoChishun Added.
     */
    public function kindeupload() {
        $msg=sofn_file_upload(array('savePath'=>'Product/','maxSize'=>500*1024*1024,'skipEmpty'=>true));
        if(is_array($msg)){
            $result=array('error' => 0, 'url' =>$msg['imgFile']['filepath']);
        }else{
            $result=array('error' => 1, 'message' => $msg);
        }
        $this->ajaxReturn($result);
    }
}